/*
 * This bean serves to hold the ID of whatever is the current outlet that is accessible for editing by Outlet Manager.
 */
package managedBean.TX.OutletManagement;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import entity.*;
import java.util.List;
import javax.ejb.EJB;
import session.TX.*;

/**
 *
 * @author Randall Chia
 */
@ManagedBean (name="TrackerOutletAdmin")
@SessionScoped
public class TrackerManagedOutletMB {
    
    @EJB
    private OutletSBRemote outletManager;
    

    private Long outletId;
    private String outletName;
    private String outletOwner; //the name of the stakeholder who owns the outlet
    
    


    /** Creates a new instance of TrackerManagedOutletMB */
    public TrackerManagedOutletMB() {
        System.out.println(">>> TrackerManagedOutletMB initialised");
    }
    

    //This method is used to set the current outlet to be Managed by retrieving its ID
    public void accessOutlet(Long id){
        Outlet outlet = outletManager.getOutlet(outletId);
        
        if (outlet == null){
            System.out.println(">>> TrackerManagedOutletMB: Cound not find outlet");
            return;
        }
        else {
            outletId = outlet.getId();
            outletName = outlet.getOutletName();
            setOutletOwner(outlet.getStakeholder().getName());
            System.out.println(">>> TrackerManagedOutletMB: Outlet found: " + outletId + " " + getOutletOwner() + " " + outletName);
        }
    }
    
    
    
    //============================================================================================================

    /**
     * @return the outletId
     */
    public Long getOutletId() {
        return outletId;
    }

    /**
     * @param outletId the outletId to set
     */
    public void setOutletId(Long outletId) {
        this.outletId = outletId;
    }

    /**
     * @return the outletName
     */
    public String getOutletName() {
        return outletName;
    }

    /**
     * @param outletName the outletName to set
     */
    public void setOutletName(String outletName) {
        this.outletName = outletName;
    }

    /**
     * @return the outletOwner
     */
    public String getOutletOwner() {
        return outletOwner;
    }

    /**
     * @param outletOwner the outletOwner to set
     */
    public void setOutletOwner(String outletOwner) {
        this.outletOwner = outletOwner;
    }


    
    
}
